import { createRouter, createWebHashHistory } from "vue-router";
import NProgress from "nprogress"; // progress bar
import "nprogress/nprogress.css"; // 进度条样式
import layout from "@/layout/index.vue";
NProgress.configure({ showSpinner: false }); // NProgress Configuration

const routes = [
  {
    path: "/",
    name: "layout",
    component: layout,
    meta: {
      title: "layout",
    },
    redirect: "/index",
    children: [
      {
        path: "/index",
        name: "index",
        meta: {
          title: "首页",
        },
        component: () => import("@/views/index/index.vue"),
      },
      {
        path: "/tag",
        name: "tag",
        meta: {
          title: "模块一",
        },
        component: () => import("@/views/model/tag.vue"),
      },
      {
        path: "/active",
        name: "active",
        meta: {
          title: "活动",
        },
        component: () => import("@/views/model/active.vue"),
      },
      {
        path: "/manage/upload",
        name: "upload",
        component: () => import("@/views/user/upload.vue"),
        meta: {
          title: "上传图片",
        },
      },
      {
        path:'/person',
        name:'person',
        component:()=> import('@/views/model/person.vue'),
        meta:{
          title:"个人中心"
        }
      },
      {
        path:'/useInfo',
        name:'useInfo',
        component:()=> import('@/views/model/user.vue'),
        meta:{
          title:"作者详情"
        }
      },
      {
        path:'/department',
        name:'department',
        component:()=> import('@/views/model/department.vue'),
        meta:{
          title:"科室中心"
        }
      },
     
    ],
  },

  {
    path: "/manage",
    name: "userCenter",
    component: () => import("@/views/user/index.vue"),
    redirect: "/manage/home",
    children: [
      {
        path: "/manage/home",
        name: "home",
        component: () => import("@/views/user/home.vue"),
        meta: {
          title: "首页",
        },
      },
      {
        path: "/manage/album",
        name: "album",
        component: () => import("@/views/user/album.vue"),
        meta: {
          title: "相册管理",
        },
      },
      {
        path: "/manage/auth",
        name: "auth",
        component: () => import("@/views/user/auth.vue"),
        meta: {
          title: "权限管理",
        },
      },
      {
        path: "/manage/permission",
        name: "permission",
        component: () => import("@/views/user/permission.vue"),
        meta: {
          title: "授权管理",
        },
      },
      {
        path: "/manage/collect",
        name: "collect",
        component: () => import("@/views/user/collect.vue"),
        meta: {
          title: "我的收藏",
        },
      },
      {
        path: "/manage/office",
        name: "office",
        component: () => import("@/views/user/office.vue"),
        meta: {
          title: "部门管理",
        },
      },
      {
        path: "/manage/photo",
        name: "photo",
        component: () => import("@/views/user/photo.vue"),
        meta: {
          title: "照片管理",
        },
      },
      {
        path: "/manage/user",
        name: "user",
        component: () => import("@/views/user/user.vue"),
        meta: {
          title: "用户管理",
        },
      },
      {
        path: "/manage/userDetail",
        name: "userDetail",
        component: () => import("@/views/user/userDetail.vue"),
        meta: {
          title: "用户详情",
        },
      },
      {
        path: "/manage/waitList",
        name: "waitList",
        component: () => import("@/views/user/wait.vue"),
        meta: {
          title: "待审核列表",
        },
      },
      {
        path:'/manage/theme',
        name:'theme',
        component:()=> import('@/views/user/theme.vue'),
        meta:{
          title:"主题管理"
        }
      }
    ],
  },
];

const router = createRouter({
  history: createWebHashHistory(),
  routes,
});

router.beforeEach((to, form, next) => {
  NProgress.start(); // start progress bar
  next();
});

router.afterEach(() => {
  NProgress.done(); // finish progress bar
});

export default router;
